package top.yehot.cmmu.core.base;

import lombok.Getter;
import top.yehot.cmmu.core.enums.JBaseCode;
import top.yehot.cmmu.core.enums.JResCodeEnum;

/**
 * 自定义异常
 * 
 * @author lquan
 * @date 2022-9-10 11:35:28
 */
public class JBaseException extends RuntimeException {

	private static final long serialVersionUID = 1L;
	private static final String logErrorCode = "状态码：";
	private static final String logErrorMsg = "错误信息：";
	
	@Getter
	private Integer status;
	@Getter
	private String message;

	public JBaseException(String message) {
		super(logErrorMsg + message);
		this.status = JResCodeEnum.INNER_ERROR.getStatus();
		this.message = message;
	}
	
	public JBaseException(Throwable e) {
		super(logErrorMsg + e.getMessage(), e);
		this.status = JResCodeEnum.INNER_ERROR.getStatus();
		this.message = JResCodeEnum.INNER_ERROR.getMessage();
	}
	
	public JBaseException(String message, Throwable e) {
		super(logErrorMsg + message, e);
		this.status = JResCodeEnum.INNER_ERROR.getStatus();
		this.message = message;
	}
	
	public JBaseException(JBaseCode e) {
		super(logErrorCode + e.getStatus() + "，" + logErrorMsg + e.getMessage());
		this.status = e.getStatus();
		this.message = e.getMessage();
	}
	
	public JBaseException(Integer status, String message) {
		super(logErrorCode + status + "，" + logErrorMsg + message);
		this.status = status;
		this.message = message;
	}
	
	public JBaseException(Integer status) {
		super(logErrorCode + status);
		this.status = status;
		this.message = "";
	}
	
}
